home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
t_os
/
mu_tool
/
bascomp.awk
next >
Wrap
Text File
|
1993-11-30
|
996b
|
34 lines
# BASIC Program Optimizer
# delete spaces
# delete comments
#
# outf output file name (given by batch file)
# ix index for space scanning
{
if (match($0,/^([^"]*"[^"]*")*[^"^']*'/) == 1)
$0 = substr($0, 1, RLENGTH-1) # remove comment
gsub(/ +$/,"") # remove spaces at tail
match($0,/ +/) # remove spaces after line number
ix = RSTART+1
$0 = substr($0,1,RSTART) substr($0,RSTART+RLENGTH)
while (match(substr($0,ix),/^([^"^ ]*"[^"]*")*[^"^ ]* /) != 0){
ix = ix + RLENGTH-2
if (match(substr($0,ix),/^[A-Z0-9] +[A-Z0-9]/)){
$0 = substr($0,1,ix) substr($0,ix-2+RLENGTH)
ix += 2
}
else{
match(substr($0,ix),/^. +[^ ]/)
$0 = substr($0,1,ix) substr($0,ix-1+RLENGTH)
ix ++
}
}
}
NF > 1 {
# print $0
print $0 > outf # output line
}